<script setup lang="ts">
import { computed } from "vue";
import { RouterLink, useRoute } from "vue-router";
import { viewRoutes } from "./router/routes";

const route = useRoute();
const meta = computed(() => route.meta);
const menu = computed(() => {
  return viewRoutes
    .filter((item) => item.meta.pid === 0 && item.meta.isMenu === true)
    .sort((a, b) => a.meta.order - b.meta.order);
});
</script>

<template>
  <div class="menu-box">
    <router-link
      class="menu-item"
      v-for="(item, index) in menu"
      :key="index"
      :to="item.path"
    >
      {{ item?.meta.title }}
    </router-link>
  </div>
  <div class="main-box">
    <div>名称：{{ route.name }}</div>
    <div>描述：{{ meta.desc }}</div>
  </div>
  <router-view />
</template>

<style scoped>
.menu-box {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid #ccc;
  height: 120px;
}
.menu-item {
  margin: 0 10px;
  font-size: 20px;
  text-decoration: none;
  color: black;
  cursor: pointer;
}
.main-box {
  padding: 20px 0;
  border-bottom: 1px solid #ccc;
}
h1 {
  font-size: inherit;
  font-weight: normal;
}
</style>
